from django.contrib.auth.mixins import LoginRequiredMixin
from django import http

from meiduo_mall.utils.response_code import RETCODE


# 重写LoginRequiredMixin 方法，原因是 handle_no_permission返回的对象不是json数据格式
class LoginRequiredJsonMixin(LoginRequiredMixin):
    def handle_no_permission(self):
        return http.JsonResponse({"code": RETCODE.SESSIONERR, "errmsg": "用户未登录"})